package com.shop.bookstore.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/main")
public class MainController {
    @Autowired
    HttpServletRequest request;
    @RequestMapping("/welcome")
    public String goodsList(Model model){
        Object username= request.getSession().getAttribute("username");
        if(username==null){
            return "redirect:/";
        }else {
            return "welcome";
        }
    }
}
